<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>物品新增或修改申请</title>
		<link rel="stylesheet"
			href="${pageContext.request.contextPath }/css/base.css" />
		<link rel="stylesheet"
			href="${pageContext.request.contextPath }/css/info-mgt.css" />
		<link rel="stylesheet"
			href="${pageContext.request.contextPath }/css/WdatePicker.css" />

		<script type="text/javascript"
			src="${pageContext.request.contextPath }/js/jquery.js"></script>
		<script type="text/javascript"
			src="${pageContext.request.contextPath }/js/common.js"></script>
		<script type="text/javascript"
			src="${pageContext.request.contextPath }/js/WdatePicker.js"></script>
		<script type="text/javascript"
			src="${pageContext.request.contextPath }/js/jquery.pagination.js"></script>
	</head>
	<body>
		<div class="title">
			<h2>
				公共物品申请记录
			</h2>
		</div>
		<form method="post"
			action="${pageContext.request.contextPath }/ComMethod.action?method=selectAppCom">
			<div class="query">
				<div class="query-conditions ue-clear">
					<div class="conditions name ue-clear">
						<label>
							物品编号：
						</label>
						<p class="long-input ue-clear">
							<input type="text" name="comid" id="comid" value="${requestScope.selchange.comId}"/>
						</p>
					</div>
					<div class="conditions name ue-clear">
						<label>
							物品名称：
						</label>
						<p class="long-input ue-clear">
							<input type="text" name="comname" id="comname" value="${requestScope.selchange.comName}"/>
						</p>
					</div>
					<div class="conditions name ue-clear">
						<label>
							申请金额：
						</label>
						<p class=short-input ue-clear">
							<input type="text" name="minprice" id="minprice" value="${requestScope.selchange.minPrice}"/>
							-<input type="text" name="maxprice" id="maxprice"value="${requestScope.selchange.maxPrice}">
						</p>
					</div>
					<div class="conditions name ue-clear">
						<label>
							申请类型
						</label>
						<p class="long-input ue-clear">
							<select id="applystatus" name="appcomstatus">
								<option>请选择</option>
								<option>新增</option>
								<option>修改</option>
							</select>
						</p>
					</div>
					<div class="conditions name ue-clear">
						<label>
							物品类型
						</label>
						<p class="long-input ue-clear">
							<select id="comtype" name="comtype">
								<option>请选择</option>
								<option>办公用品</option>
								<option>公共资源</option>
							</select>
						</p>
					</div>
					<div class="conditions name ue-clear">
						<label>
							申请状态
						</label>
						<p class="long-input ue-clear">
							<select id="status" name="status">
								<option>请选择</option>
								<option>待审批</option>
								<option>已通过</option>
								<option>未通过</option>
							</select>
						</p>
					</div>
					<div class="query-btn ue-clear">
						<input type="submit" id="submit" value="查询" />
						&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
						<input type="reset" id="reset" value="重置">
					</div>
				</div>
			</div>
		</form>
		<div class="table-box">
			<table>
				<thead>
					<tr>
						<th class="num">
							申请编号
						</th>
						<th class="name">
							物品id
						</th>
						<th class="process">
							物品名称
						</th>
						<th class="time">
							物品类型
						</th>
						<th class="time">
							申请类型
						</th>
						<th class="node">
							新增/修改数量
						</th>
						<th class="time">
							申请金额
						</th>
						<th class="time">
							处理人
						</th>
						<th class="time">
							处理日期
						</th>
						<th class="operate">
							状态
						</th>
						<th class="operate">
							操作
						</th>
					</tr>
				</thead>
				<c:forEach items="${requestScope.changeapplist.data}" var="changeappcom"
					varStatus="c">
					<tbody>
						<tr>
							<td class="num">
								${changeappcom.cruuId }
							</td>
							<td class="name">
								${changeappcom.cruComId }
							</td>
							<td class="process">
								${changeappcom.cruName }
							</td>
							<td>
								${changeappcom.cruComType }
							</td>
							<td class="node">
								${changeappcom.cruType }
							</td>
							<td class="time">
								${changeappcom.cruNum }
							</td>
							<td class="time">
								${changeappcom.cruPrice }
							</td>
							<td class="time">
								${changeappcom.cruHandler }
							</td>
							<td class="time">
								${changeappcom.cruHandleTime }
							</td>
							<c:if test="${changeappcom.cruStatus == 0 }">
								<td>
									待审核
								</td>
								<td class="operate">
									<label style="cursor: pointer; color: blue" onclick="passapp('${changeappcom.cruuId }','${login_User.userName }','${requestScope.changeapplist.currentPage}','${changeappcom.cruComId }','${changeappcom.cruComType }')">
										通过
									</label>
									&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									<label style="cursor: pointer; color: blue" onclick="refuseapp('${changeappcom.cruuId }','${login_User.userName }','${requestScope.changeapplist.currentPage}','${changeappcom.cruComId }')">
										拒绝
									</label>
								</td>
							</c:if>
							<c:if test="${changeappcom.cruStatus == 1 }">
								<td>
									已通过
								</td>
								<td class="operate">
									<label style="color: gray">
										通过
									</label>
									&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									<label style="color: gray">
										拒绝
									</label>
								</td>
							</c:if>
							<c:if test="${changeappcom.cruStatus == -1 }">
								<td>
									未通过
								</td>
								<td class="operate">
									<label style="color: gray">
										通过
									</label>
									&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									<label style="color: gray">
										拒绝
									</label>
								</td>
							</c:if>
						</tr>
					</tbody>
				</c:forEach>
			</table>
		</div>
		<div>
			<table width="80%" align="center" cellspacing="0" cellpadding="0">
				<tr>
					<td>
						<a onclick=skipPage('1');;>首页</a>
					</td>
					<td>
						<a
							onclick="skipPage('${requestScope.changeapplist.currentPage==1?1:requestScope.changeapplist.currentPage-1 }');">上一页</a>
					</td>
					<td>
						<a
							onclick="skipPage('${requestScope.changeapplist.currentPage==requestScope.changeapplist.totalPage?(requestScope.changeapplist.currentPage):(requestScope.changeapplist.currentPage+1) }');">下一页</a>
					</td>
					<td>
						<a onclick="skipPage('${requestScope.changeapplist.totalPage}');">末页</a>
					</td>
					<td>
						当前页码：${requestScope.changeapplist.currentPage}/${requestScope.changeapplist.totalPage}
					</td>
				</tr>
			</table>
		</div>
	</body>
	<script type="text/javascript">
	window.onload=function(){
		$("#applystatus option").each(function() {
			if($(this).val()=='${requestScope.selchange.type}'){
				$(this).attr('selected',true);
			}
		});
		$("#comtype option").each(function() {
			if($(this).val()=='${requestScope.selchange.comType}'){
				$(this).attr('selected',true);
			}
		});
		
		$("#status option").each(function() {
			if($(this).val()=='${requestScope.selchange.status}'){
				$(this).attr('selected',true);
			}
		});
		
		if('${requestScope.op}'=='1'){
			alert("操作成功");
		}else if('${requestScope.op}'=='0'){
			alert("操作失败,请重试");
		}
	}
	function skipPage(currentPage){
		var url ='${pageContext.request.contextPath }/ComMethod.action?method=selectAppCom&currPage=' + currentPage;
		url += '&comname=' + document.getElementById("comname").value;
		url += '&minprice=' + document.getElementById("minprice").value;
		url += '&maxprice=' + document.getElementById("maxprice").value;
		url += '&comid=' + document.getElementById("comid").value;
		url += '&appcomstatus=' + document.getElementById("applystatus").value;
		url += '&comtpye=' + document.getElementById("comtype").value;
		url += '&status=' +document.getElementById("status").value;
		window.location.href = url;
	}
	function passapp(id,handler,currentPage,comid,comtype111){
		var a = confirm("确认通过?");
		var url = '${pageContext.request.contextPath }/ComMethod.action?method=passcomchangeapp&currPage=' + currentPage;
		url += '&comname=' + document.getElementById("comname").value;
		url += '&minprice=' + document.getElementById("minprice").value;
		url += '&maxprice=' + document.getElementById("maxprice").value;
		url += '&comid=' + document.getElementById("comid").value;
		url += '&appcomstatus=' + document.getElementById("applystatus").value;
		url += '&comtpye=' + document.getElementById("comtype").value;
		url += '&id=' + id;
		url += '&handler=' + handler;
		url += '&comtype111='+comtype111;
		url += '&comid1111=' + comid;
		if(a){
			window.location.href = url;		
		}else{
			return false;
		}
	}
	function refuseapp(id,handler,currentPage,comid){
		var a = confirm("确认拒绝?");
		var url = '${pageContext.request.contextPath }/ComMethod.action?method=refusecomchangeapp&currPage=' + currentPage;
		url += '&comname=' + document.getElementById("comname").value;
		url += '&minprice=' + document.getElementById("minprice").value;
		url += '&maxprice=' + document.getElementById("maxprice").value;
		url += '&comid=' + document.getElementById("comid").value;
		url += '&appcomstatus=' + document.getElementById("applystatus").value;
		url += '&comtpye=' + document.getElementById("comtpye").value;
		url += '&id=' + id;
		url += '&handler=' + handler;
		url += '&comid1111=' + comid;
		if(a){
			window.location.href = url;		
		}else{
			return false;
		}
	}
	</script>
</html>
